home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c
- Subject: Re: Is it possible to #include <#defined or -D 'ed macro>?
- Date: 25 Jan 1996 20:47:37 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Jan25134737@qcd.lanl.gov>
- References: <5rbuntgqp0.fsf@ritz.mordor.com> <4e8bbd$nl7@crl.crl.com>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: bobfry@crl.com's message of 25 Jan 1996 08:32:45 -0800
-
- --text follows this line--
- In article <4e8bbd$nl7@crl.crl.com> bobfry@crl.com (Robert Fry) writes:
- <snip>
- benjamin@ritz.mordor.com (Joseph Thomas) writes:
-
- >Does anyone know a way of having an include statement that can include
- >a file, based on a -D <MACRO_NAME> flag passed to the compiler, to
- >give the effect of:
-
- >#include <SOURCE>
-
- >cc -D SOURCE=source_a.h
-
- >includes source_a.h
-
- >and
-
- >cc -D SOURCE=source_b.h
-
- >includes source_b.h, (this doesn't seem to work with the xlc compiler)
-
- Try
-
- #define STRIG(X) #X
- #define STR(X) STRING(X)
-
- #include STR(SOURCE)
-
- Except for loose wording of the standard, if SOURCE is #defined as
- source_a.h, this is completely equivalent to #include "source_a.h".
-
- or
-
- #define HEADER
- #include HEADER<SOURCE>
-
- which maybe equivalent to #include <source_a.h>. I say maybe, because
- the standard requires the implementation to document how it interprets
- this line: and the documented interpretation need not be
- <source_a.h> (though, there is no reason why it should choose anything
- else.)
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-